package com.fz.us.admin.company.entity;

import javax.persistence.*;
import java.util.Set;

/**
 * Created by ZhuChunXiao on 2017/5/26.
 */
@Entity
@Table(name="sys_group")
public class Group extends CompanyEntity {

    private static final long serialVersionUID = 4342836869510702292L;

    /**
     *别名
     */
    private String pName;

    /**
     * 描述
     */
    private String description;
    /**
     * 用户
     */
    private Set<User> usersSet;
    /**
     * 部门
     */
    private Set<Department> departSet;
    /**
     * 职权
     */
    private Set<Power> powerSet;



    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name="sys_group_power",joinColumns = @JoinColumn(name="id"),inverseJoinColumns = @JoinColumn(name="powerid"))
    @OrderBy("name asc")
    public Set<Power> getPowerSet() {
        return powerSet;
    }

    public void setPowerSet(Set<Power> powerSet) {
        this.powerSet = powerSet;
    }

    public String getpName() {
        return pName;
    }

    public void setpName(String pName) {
        this.pName = pName;
    }

    @Column(length = 5000)
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @OrderBy("name asc")
    public Set<User> getUsersSet() {
        return usersSet;
    }

    public void setUsersSet(Set<User> usersSet) {
        this.usersSet = usersSet;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name="sys_group_depart",joinColumns = @JoinColumn(name="id"),inverseJoinColumns = @JoinColumn(name="depid"))
    @OrderBy("name asc")
    public Set<Department> getDepartSet() {
        return departSet;
    }

    public void setDepartSet(Set<Department> departSet) {
        this.departSet = departSet;
    }
}
